
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author RaiJin
 */
public class Collection {
    HashMap<Integer,Phone> Collec = new HashMap<>();
    HashMap<Integer,Phone> Collec2 = new HashMap<>();
    Iterator it;
    public void add(Phone newPhone){
        Collec.put(Collec.size(), newPhone);
    }
    
    public void search(String newProducer){
        it = Collec.keySet().iterator();
        while(it.hasNext()){
            Object key = it.next();
            if(Collec.get(key).producer.equals(newProducer)){
                Collec2.put(Collec2.size(), Collec.get(key));
            }
        }
    }
    
    public void searchInfo(String newCode,String newName,String newPrice){
        it = Collec.keySet().iterator();
        while(it.hasNext()){
            Object key = it.next();
            if(Collec.get(key).code.equals(newCode)||Collec.get(key).name.equals(newName)||Collec.get(key).price.equals(newPrice)){
                Collec2.put(Collec2.size(), Collec.get(key));
            }
        }
    }
}
